package com.netease.nim.uikit.team.helper;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * Created by nick on 2017/9/27.
 * 家族自定义文案
 */

public class TeamNotifyContentHelper {

    public static String getContentByCustomerNotifyMessage(String json){
        try {
            JSONObject object = JSON.parseObject(json);
            int type = object.getIntValue("type");
            String  name = object.getString("name");
            String  title = "";
            if (object.containsKey("title")){
                  title = object.getString("title");
            }
            int lv = 0;
            if (object.containsKey("lv")){
                lv  = object.getIntValue("lv");
            }
            return getTextByType(type,lv,name,title);
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }

    private static String getTextByType(int type,int level,String name,String levelTitle){
        StringBuffer buffer = new StringBuffer();
        switch (type){
            case 104:
                buffer.append(name).append(" 被撤销了长老职位");
                break;
            case 106:
                buffer.append(name).append(" 提升为长老");
                break;
            case 107:
                buffer.append(name).append(" 的家族等级提升为 ").append("[").append(levelTitle).append("]");
                break;
            case 108:
                buffer.append(" 家族等级提升为 ").append(level).append("级");
                break;
        }
        return buffer.toString();

    }
}
